package com.lechuang.controller;

import com.alibaba.fastjson.JSONObject;
import com.lechuang.controller.validate.BaseValidator;
import com.lechuang.model.Test;
import com.lechuang.model.User;
import com.lechuang.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * Created by Administrator on 2016/9/26.
 */
@Controller
public class TestController {


//    @Autowired
//    TestService service;
    @RequestMapping(value = "/test")
    @ResponseBody
    public String test(){
        List<String> list = new ArrayList<String>();
        list.add("中午测试 hello  ");
        BaseResult.addSuccess("z中文测试+拦截器");
        JSONObject json = new JSONObject();
        json.put("test",list);
       return json.toString();
    }

    @RequestMapping("/testView")
    @ResponseBody
    public String test2(HttpServletRequest request){
        new BaseValidator().validate(request);
        request.setAttribute("test","中午测试");
        return "/mobile/login.html";
    }

    @RequestMapping("testBean")
    @ResponseBody
    public void testBean(){
        ApplicationContext context;
//        User test = service.test();
//        BaseResult.addSuccess(test);
    }

}
